package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.domain.R;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.framework.web.service.TokenService;
import com.zzyl.nursing.domain.NursingPlan;
import com.zzyl.nursing.dto.BindElderDto;
import com.zzyl.nursing.dto.QueryDeviceDataDto;
import com.zzyl.nursing.dto.QueryDevicePropertyStatusDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 老人家属Controller
 *
 * @author ruoyi
 * @date 2024-09-02
 */
@RestController
@RequestMapping("/member/user")
@Api(tags =  "老人家属相关接口")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;

    @PostMapping("/login")
    @ApiOperation("小程序登录")
    public AjaxResult login(@RequestBody UserLoginRequestDto userLoginRequestDto) {
        LoginVo loginVo = familyMemberService.login(userLoginRequestDto);
        return success(loginVo);
    }

    /**
     * 绑定老人
     * @param dto
     * @return
     */
    @PostMapping("/add")
    public AjaxResult bindELder(@RequestBody BindElderDto dto){
    familyMemberService.bindELder(dto);
    return success();
}

    /**
     * 查看家人列表
     * @return
     */
    @GetMapping("/my")
    public R<List<BindElderVo>> getall(){
        return R.ok(familyMemberService.getall());
    }
    /**
     * 查看家人列表,分页查询
     * 目前这个接口存在bug,不能实现分页,后续会优化
     * 新:个人任务这个接口不应该实现分页查询,
     * 第一:我们不可能绑定这么多家人
     * 第二,接口文档提供返回给前端的数据信息并不是分页查询
     */
    @GetMapping("/list-by-page")
    public R<List<PageVo>> pageList()
    {
        List<PageVo> list=familyMemberService.pageList();
        return R.ok(list);
    }
    /**
     * 查询健康数据
     */
    @PostMapping ("/QueryDevicePropertyStatus")
    public R<DeviceStatusDataVO> queryDeviceProperty(@RequestBody QueryDevicePropertyStatusDto dto){
        DeviceStatusDataVO list=familyMemberService.queryDeviceProperty(dto);
        return R.ok(list);
    }
    /**
     * 按照天数统计指标数据
     */
    @GetMapping("/queryDeviceDataListByDay")//键值对请求
    public R<List<TimeSeriesDataVO>> queryDeviceDataListByDay( QueryDeviceDataDto dto){
        List<TimeSeriesDataVO> vo=familyMemberService.queryDeviceDataListByDay(dto);
        return R.ok(vo);
    }
    /**
     * 按周统计数据
     */
    @GetMapping("/queryDeviceDataListByWeek")//键值对请求
    public R<List<TimeSeriesDataVO>> queryDeviceDataListByWeek( QueryDeviceDataDto dto){
        List<TimeSeriesDataVO> vo=familyMemberService.queryDeviceDataListByWeek(dto);
        return R.ok(vo);
    }
}